/**
 * Created by wsx on 2017/1/6.
 */
$(function () {
    var uemailflag = false;
    var upasswdflag = false;
    var upasswdconflag = false;
    $('#uemail').blur(function () {
        if("" == $(this).val()){
            $('#dis_uemail').text("please input uemail");
            uemailflag = false;
        }else{
            uemailflag = true;
            $('#dis_uemail').text("");
        }
    });
    $('#upasswd').blur(function () {
        if("" == $(this).val()){
            $('#dis_upasswd').text("please input upasswd");
            upasswdflag = false;
        }else{
            upasswdflag = true;
            $('#dis_upasswd').text("");
        }
    });
    $('#upasswd_con').blur(function () {
        if("" == $(this).val()){
            $('#dis_upasswd_con').text("please input upasswd_con");
            upasswdconflag = false;
        }else{
            if("" == $('#upasswd').val()){
                $('#dis_upasswd_con').text("please input upasswd");
                upasswdconflag = false;
            }else{
                if($('#upasswd').val() == $('#upasswd_con').val()){
                    upasswdconflag = true;
                    $('#dis_upasswd_con').text("");
                }else{
                    $('#dis_upasswd_con').text("Two input passwords are not consistent");
                    upasswdconflag = false;
                }
            }
        }
    });
    $('#regbt').click(function () {
        $.ajax({
            type: "POST",
            url: "/register",
            data: {
                uname: $('#uname').val(),
                uemail: $('#uemail').val(),
                uphone: $('#uphone').val(),
                upasswd: $('#upasswd').val()
            },
            dataType :"text",
            success: function (data) {
                if("true" == data) {
                    alert("注册成功");
                    location.href = "/";
                }else{
                    alert("系统错误");
                }
            }
        });
    });
});